package com.ksd.oauth2;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder;

/** 
* 
* @author zbb: 
* @version 2017年9月14日
* 
*/

public class Md5PasswordEncoderExt extends MessageDigestPasswordEncoder {
	
	private static Logger logger = Logger.getLogger(Md5PasswordEncoderExt.class);
	
	public Md5PasswordEncoderExt() {
		super("MD5");
	}

	@Override
	public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
		logger.debug("password valid");
		String pass1 = "" + encPass;

        String pass2 = DigestUtils.md5Hex(DigestUtils.md5Hex(rawPass)  + salt);
        
        return pass1.equals(pass2);
			
	}
	
	
}
